package com.example.lyqwork.repository;

import com.example.lyqwork.pojo.CarOrder;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;


public interface CarOrderRepository extends JpaRepository<CarOrder, Integer> {
    //通过用户id查找订单
    @Query("SELECT o FROM CarOrder o WHERE o.userId = :userId ORDER BY o.orderId DESC")
    List<CarOrder> findByUserIdOrderByOrderIdDesc(@Param("userId") Integer userId, Pageable pageable);
    //通过订单号查找订单
    @Query("SELECT o FROM CarOrder o WHERE o.orderId = :orderId ORDER BY o.orderId DESC")
    List<CarOrder> findByOrderIdOrderByOrderIdDesc(@Param("orderId") Integer orderId, Pageable pageable);

}
